﻿/*
Copyright © 2010 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See <license.txt> for the complete license of the software.
*/

namespace MSBuild.Mercurial
{
    /// <summary>
    /// Pushes the changes to a specified destination.
    /// </summary>
    /// <remarks>
    /// This method use the <c>hg push</c> command.
    /// </remarks>
    /// <example>
    /// Push all the changes to the parent repository of the current MSBuild project:
    /// <code><![CDATA[
    /// <HgPush
    ///     LocalPath="$(MSBuildProjectDirectory)" />
    /// </example>
    /// ]]></code>
    /// Update a remote repository with the User and Password properties:
    /// <code><![CDATA[
    /// <HgPush
    ///     LocalPath="$(MSBuildProjectDirectory)"
    ///     Repository="http://domain/repos"
    ///     User="$(HgUser)"
    ///     Password="$(HgPassword)" />
    /// </example>
    /// ]]></code>
    /// Update a remote repository without the User and Password properties:
    /// <code><![CDATA[
    /// <HgPush
    ///     LocalPath="$(MSBuildProjectDirectory)"
    ///     Repository="http://$(HgUser)@$(HgPassword):domain/repos" />
    /// </example>
    /// ]]></code>
    /// This last sample has the following drawbacks:
    /// <list type="bullet">
    /// <item>it works only if the HgUser ang HgPassword are defined</item>
    /// <item>it works only if there is no space and special chars in those values</item>
    /// </list>
    /// </example>
    [Command("push")]
    public class HgPush : AbstractRemoteTask
    {
        /// <summary>
        /// Gets or sets a value indicating whether the push
        /// should be forced.
        /// </summary>
        [Parameter("-f")]
        public bool Force { get; set; }

        /// <summary>
        /// Gets or sets a specific revision up to which the push
        /// will be done.
        /// </summary>
        [Parameter("-r")]
        public string Revision { get; set; }

        /// <summary>
        /// Gets or sets the ssh command to use.
        /// </summary>
        [Parameter("-e")]
        public string Ssh { get; set; }

        /// <summary>
        /// Gets or sets the destination of the push.
        /// </summary>
        /// <remarks>
        /// <para>If omitted, a default path could be used. This one
        /// should be defined in the workspace configuration.
        /// </para>
        /// <para>
        /// This path could be a remote repository and will be impacted by
        /// the <see cref="AbstractRemoteTask.User"/> and
        /// <see cref="AbstractRemoteTask.Password"/> properties.
        /// </para>
        /// </remarks>
        [Parameter("")]
        public string Destination
        {
            get { return this.Repository; }
            set { this.Repository = value; }
        }
    }
}
